import axios from "axios";
import {ElNotification} from "element-plus";
import router from "../router/index.js";
axios.defaults.baseURL="https://122.228.26.226:58203/hos"


export function loginRequest(context,loginData){
    console.log('Requesting login with data:', loginData);
    axios.get('/user/login',{ params: loginData })
        .then(response=>{
            console.log('Response received:', response);
            localStorage.setItem('userName',response.data.user.username)
            ElNotification({title: 'Success', message: '登陆成功', type:'success'})
            router.push('/layout')
        })
        .catch(error=>{
            console.log(error)
            // ElNotification({title: 'Error', message: error.response.data.error, type:'error'})
            ElNotification({title: 'Error', message: error.response?.data?.error || '请求失败', type: 'error'});
        })
}